import java.util.EmptyStackException;

class MyStack implements RPNStack {
	private int size = 0;
	MyStack next;
	double value;

	public MyStack() {
	}

	public MyStack(double value) {
		this.value = value;
	}

	public int size() {
		return size;
	}

	public void clear() {
		next = null;
		size = 0;
	}

	public boolean empty() {
		if (size == 0)
			return true;
		else
			return false;
	}

	public void push(double value) {
		MyStack next = new MyStack(value);
		MyStack temp = this.next;

		this.next = next;
		this.next.next = temp;

		size++;
	}

	public double pop() {
		MyStack next = this.next;

		if (next == null) throw new EmptyStackException();

		this.next = next.next;

		size--;

		return next.value;
	}
}
